package com.meilai.project.controller.web.report.entity;

import cn.hutool.core.util.StrUtil;
import com.meilai.project.controller.web.market.entity.BillMarketShootRequirement;
import lombok.Data;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

/**
 * @author chenxing
 */
@Data
public class BillMarketShootRequirementExt extends BillMarketShootRequirement {

    private static DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd");

    private Long customer_id;
    private String customer_name;

    private LocalDate start_at;
    private LocalDate end_at;
    private LocalDate latest_up_date;
    private Integer latest_up_time;
    private LocalDate latest_down_date;
    private Integer latest_down_time;
    private Boolean has_new_pic;
    private Boolean show_proxy_flag;
    private Boolean pic_need_recycle;

    public String dateRangeStr() {
        return start_at.format(formatter) + "~" + end_at.format(formatter);
    }

    //最晚上刊时间
    private String lastUpStr() {
        return latest_up_date.format(formatter) + " " + (1 == latest_up_time ? "上午" : "下午");
    }

    //最晚下刊时间
    private String lastDownStr() {
        return latest_down_date.format(formatter) + " " + (1 == latest_down_time ? "上午" : "下午");
    }

    private String hasNewPic() {
        return null == has_new_pic || !has_new_pic ? "无新画面" : "有新画面";
    }

    private String showProxyFlag() {
        return null == show_proxy_flag || !show_proxy_flag ? "不显示代理资源标识" : "显示代理资源标识";
    }

    private String recyclePic() {
        return null == pic_need_recycle || !pic_need_recycle ? "不回收画面" : "回收画面";
    }

    public String description() {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
        String result = "时间：";
        if (null != getShoot_date()) {
            result += getShoot_date().format(dateTimeFormatter) + "\n";
        } else {
            result += "-\n";
        }

        if (null != getWatermark_time() && getWatermark_time()) {
            result += "水印时间\n";
        }
        if (null != getBaidu_time() && getBaidu_time()) {
            result += "百度时间\n";
        }
        if (null != getNewspaper_time() && getNewspaper_time()) {
            result += "报纸时间\n";
        }
        if (null != getNormal_shoot() && getNormal_shoot()) {
            result += "正常拍摄\n";
        }

        if (null != getBackground_clear() && getBackground_clear()) {
            result += "背景清晰\n";
        }

        if (null != getNewpaper_clear() && getNewpaper_clear()) {
            result += "报纸清晰\n";
        }

        if (null != getClose_shoot_num() && getClose_shoot_num() > 0) {
            result += "近景：" + getClose_shoot_num() + "张\n";
        }

        if (null != getFar_shoot_num() && getFar_shoot_num() > 0) {
            result += "远景：" + getFar_shoot_num() + "张\n";
        }

        if (getShoot_type() == 1) {
            //上刊
            result += hasNewPic() + "\n";
            result += "最晚上刊时间：" + lastUpStr() + "\n";
            result += showProxyFlag() + "\n";
            result += "调度备注：" + getMemoStr() + "\n";
        } else if (getShoot_type() == 2) {
            //下刊
            result += "最晚下刊时间：" + lastDownStr() + "\n";
            result += showProxyFlag() + "\n";
            result += recyclePic() + "\n";
            result += "调度备注：" + getMemoStr() + "\n";
        } else if (getShoot_type() == 3) {
            result += showProxyFlag() + "\n";
            result += "调度备注：" + getMemoStr() + "\n";
        } else {
            result += showProxyFlag() + "\n";
            result += recyclePic() + "\n";
            result += "调度备注：" + getMemoStr() + "\n";
        }

        return result + "\n";
    }

    private String getMemoStr(){
        return StrUtil.isEmpty(getMemo()) ? "无" : getMemo();
    }

}
